package com.ymatou.iapi.couponmanage.old.testcase;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.iapi.couponmanage.old.parameter.QueryValidCouponCountBean;
import com.ymatou.iapi.couponmanage.old.service.QueryValidCouponCountCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.database.sqlwapper.YmtCouponBatchWapper;
import com.ymttest.utils.EnvSetup;
import com.ymttest.utils.constant.ECode;
/**
*查询买手有效的优惠券总数用例
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_QueryValidCouponCount{
	private static QueryValidCouponCountBean queryvalidcouponcountBean;
	private static QueryValidCouponCountCall queryvalidcouponcountCall;
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("查询买手有效的优惠券总数用例");
	}

	@Before
	public void caseUp() {
		queryvalidcouponcountBean=new QueryValidCouponCountBean();
		queryvalidcouponcountCall=new QueryValidCouponCountCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(queryvalidcouponcountCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_QueryValidCouponCount_001() {
		Logger.start(true,"查询买手有效的优惠券总数");
		try {
			int sellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
			queryvalidcouponcountBean.setSellerId(sellerId);

			queryvalidcouponcountCall.setData(queryvalidcouponcountBean);
			queryvalidcouponcountCall.callService();	
			
			int count = new YmtCouponBatchWapper().getQueryValidCouponCount(sellerId);
			
			Logger.verifyEquals("0", queryvalidcouponcountCall.getCode(), "验证Code");
			Logger.verifyEquals("操作成功！", queryvalidcouponcountCall.getMessage(), "验证Msg");
			Logger.verifyEquals(count, Integer.parseInt(queryvalidcouponcountCall.getCount()), "验证Msg");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P3.class})
	@TestCase
	public void Tc_QueryValidCouponCount_002() {
		Logger.start(false,"sellerid空");
		try {
			queryvalidcouponcountCall.setData(queryvalidcouponcountBean);
			queryvalidcouponcountCall.callService();	
			
			Logger.verifyEquals("0", queryvalidcouponcountCall.getCode(), "验证Code");
			Logger.verifyEquals("操作成功！", queryvalidcouponcountCall.getMessage(), "验证Msg");
			Logger.verifyEquals("0", queryvalidcouponcountCall.getCount(), "验证Msg");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}